﻿
@{
    ViewBag.Title = "客户存货明细报表";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}

<table id="dg" class="easyui-datagrid" style="width:100%; height: 750px;" toolbar="#tb" title="客户存货明细报表" rownumbers="true" pagination="false" fitcolumns="true" singleselect="true" showFooter="true">
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <span>仓库</span>
    <input id="SelectWareHouseId" class="easyui-combobox" style="width: 173px; height: 30px;" />
    <span>查询日期</span>
    <input class="easyui-datebox" name="SummaryTime" id="SummaryTime" style="width: 173px; height: 30px; ">
    <span>客户名称</span>
    <input type="hidden" id="hdselectKeyword" />
    <input name="SelectCustomer" id="SelectCustomer" class="easyui-combobox" style="width: 173px; height: 30px;" />

    <span>商品批号</span>
    <input id="GoodsCode" class="easyui-textbox " style="width: 173px; height: 30px;" />
    <span>商品名称</span>
    <input id="GoodsName" class="easyui-textbox " style="width: 173px; height: 30px;" />
    <span>规格</span>
    <input id="GoodsSpec" class="easyui-textbox " style="width: 173px; height: 30px;" />
    <span>类型</span>
    <select id="RentalWarehouseType" class="easyui-combobox" name="RentalWarehouseType" style="width: 173px;">
        <option value=""></option>
        <option value="1">零仓</option>
        <option value="2">包仓</option>
    </select>
    <div>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-sum" onclick="doExport()">导出</a>
    </div>
    
</div>
<script src="~/Js/Global.js?v=20240701"></script>
<script language="javascript" type="text/javascript">
    $(function () {
        InitSelectCustomer();
        InitSelectWareHouse();
        initgrid();
    });

    function initgrid() {
        $('#dg').datagrid({
            url: '/Report/GetCustomerInventoryDetailReport',
            showFooter: true,
            columns: [[
                { field: 'CustomerNo', title: '客户编号', width: 80, align: 'right' },
                { field: 'CustomerName', title: '客户名称', width: 80, align: 'right' },
                { field: 'GoodsNo', title: '商品批号', width: 80, align: 'right' },
                { field: 'GoodsName', title: '商品名称', width: 80, align: 'right' },
                { field: 'GoodsSpecName', title: '规格', width: 80, align: 'right' },
                { field: 'WareHouseName', title: '仓库', width: 80, align: 'right' },
                { field: 'ContainerNumber', title: '柜号', width: 80, align: 'right' },
                { field: 'ProductionDate', title: '生产日期', width: 80, align: 'right', formatter: formatter_ProductionDate },
                { field: 'ExpirationDate', title: '过期日期', width: 80, align: 'right', formatter: formatter_ExpirationDate },
                { field: 'ProducingArea', title: '产地', width: 80, align: 'right' },
                { field: 'Remark', title: '备注', width: 80, align: 'right' },
                { field: 'Weight', title: '件重(kg)', width: 80, align: 'right' },
                { field: 'Total', title: '存货件数', width: 80, align: 'right' },
                { field: 'Area', title: '存货托盘数/面积', width: 80, align: 'right' },
                { field: 'TotalTon', title: '存货吨重', width: 80, align: 'right', formatter: formatter_TotalTon },
                { field: 'EntryTime', title: '入库时间', width: 80, align: 'right' },
                { field: 'RentalWarehouseTypeName', title: '租赁类型', width: 80, align: 'right' }
            ]],
            onLoadSuccess: function (data) {
                //var footer = $(this).datagrid().find('.datagrid-footer div[field=ProductionDate]');
                //if (footer.text() === '1970-01-01') {
                //    footer.text(''); // 或者其他你希望显示的默认值
                //}
            }
        });
    }

    function doSearch() {
        $('#dg').datagrid('load', {
            WareHouseId: $('#SelectWareHouseId').combobox('getValue'),
            SummaryTime: $('#SummaryTime').datebox('getValue'),
            CustomerId: $('#SelectCustomer').combobox('getValue'),
            GoodsCode: $('#GoodsCode').val(),
            GoodsName: $('#GoodsName').val(),
            GoodsSpec: $('#GoodsSpec').val(),
            RentalWarehouseType: $('#RentalWarehouseType').combobox('getValue')

        });
    }

    function doExport() {
        var houseid = $('#SelectWareHouseId').combobox('getValue');
        var summarytime = $('#SummaryTime').datebox('getValue');
        var customerid = $('#SelectCustomer').combobox('getValue');
        var goodscode = $('#GoodsCode').val();
        var goodsname = $('#GoodsName').val();
        var goodsspec = $('#GoodsSpec').val();
        var rentalwarehousetype = $('#RentalWarehouseType').combobox('getValue');

        //生成连接
        var url = '@Url.Content("~/Report/ExportCustomerInventoryDetailReport")' + '?houseId=' + houseid + "&summartTime=" + summarytime + "&customerid=" + customerid + "&goodscode=" + goodscode + "&goodsname=" + goodsname + "&goodsspec=" + goodsspec + "&rentalwarehousetype=" + rentalwarehousetype;
        window.open(url);
        //window.open('@Url.Content("~/Report/ExportCustomerInventoryDetailReport")' + '?houseId=' + houseid + "&summartTime=" + summarytime + "&customerid=" + customerid);
    }

    function formatter_TotalTon(value, rowData, rowIndex) {
        return rowData.TotalTon.toFixed(4);
    }

    function formatter_ProductionDate(value, rowData, rowIndex) {
        if (rowData.ProductionDate == '1911-01-01') { return ''; }
        //return formatdate(rowData.ProductionDate);
    }
    function formatter_ExpirationDate(value, rowData, rowIndex) {
        if (rowData.ExpirationDate == '1911-01-01') { return ''; }
        //return formatdate(rowData.ExpirationDate);
    }
    function formatter_EntryTime(value, rowData, rowIndex) {
        return formatdate(rowData.EntryTime);
    }


</script>

